import { type ComponentConfigModel } from '/@/views/formDesigner/utils';
export default {
  component: () => import('ant-design-vue/lib/input'),
  defaultSchema: {
    label: '计算控件',
    type: 'calc',
    field: 'input',
    icon: 'epic-icon-write',
    input: true,
    componentProps: {
      bordered: true,
      disabled: true,
      placeholder: '请输入',
    },
  },
  config: {
    attribute: [
      {
        label: '控件字段',
        type: 'input',
        field: 'name',
        componentProps: {
          placeholder: '必填项',
          require: true,
        },
      },
      {
        label: '控件名称',
        type: 'input',
        field: 'title',
        componentProps: {
          placeholder: '必填项',
          require: true,
        },
      },
      {
        label: '标签名称',
        type: 'input',
        field: 'label',
        componentProps: {
          placeholder: '必填项',
          require: true,
        },
      },
      {
        label: '算式',
        type: 'calcInput',
        field: 'formula',
        componentProps: {
          placeholder: '',
          readonly: true,
        },
        onChange: ({ value, values }) => {
          console.log({ value, values, in: value.indexOf('addDate') });
          if (value.indexOf('addDate') == 0) {
            values.spanFieldTypeDesc = '日期型';
          } else {
            values.spanFieldTypeDesc = '双精度型';
          }
        },
      },
      {
        label: '数据类型/嵌套表编码',
        type: 'input',
        field: 'spanFieldTypeDesc', //formCode
        componentProps: {
          // defaultValue: '双精度型',
          placeholder: '',
          readonly: true,
        },
      },
      {
        label: '四舍五入',
        type: 'switch',
        field: 'isRoundTo5',
        componentProps: {
          defaultValue: true,
        },
      },
      {
        label: '小数点后位数',
        describe: '需与四舍五入联用',
        type: 'number',
        field: 'digit',
        componentProps: {
          defaultValue: 2,
        },
      },
      {
        label: '格式',
        describe: '需与价格型联用',
        type: 'select',
        componentProps: {
          placeholder: '请选择',
          allowClear: true,
          options: [
            {
              label: '千分位',
              value: '0',
            },
          ],
        },
        field: 'format',
      },
      {
        label: '无穷大显示值',
        type: 'input',
        field: 'valForInfinity',
      },
      {
        label: 'NAN显示值',
        type: 'input',
        field: 'valForNaN',
      },
      {
        label: '必填项',
        type: 'switch',
        field: 'canNull',
        componentProps: {
          checkedValue: false,
          unCheckedValue: true,
        },
      },
      {
        label: '宽度',
        type: 'EInputSize2',
        field: 'widthUnit',
        componentProps: {
          defaultValue: {
            width: 150,
            unit: 'px',
          },
        },
      },
      {
        label: '长度/大小', //minT minV maxT maxV
        type: 'lenSize',
        field: 'range',
        componentProps: {
          defaultValue: {
            minT: 'd=',
            minV: '',
            maxT: 'x=',
            maxV: 100,
          },
          minTList: [
            {
              label: '>=',
              value: 'd=',
            },
            {
              label: '>',
              value: 'd',
            },
          ],
          minVList: [
            {
              label: '当前日期',
              value: 'curDate',
            },
          ],
          maxTList: [
            {
              label: '<=',
              value: 'x=',
            },
            {
              label: '<',
              value: 'x',
            },
          ],
          maxVList: [
            {
              label: '当前日期',
              value: 'curDate',
            },
          ],
        },
      },
      {
        label: '显示',
        type: 'switch',
        field: 'isShow',
        componentProps: {
          defaultValue: true,
          checkedValue: true,
          unCheckedValue: false,
        },
      },
      {
        label: '只读',
        type: 'switch',
        field: 'isReadOnly',
        componentProps: {
          readonly: true,
          defaultValue: true,
        },
      },
      {
        label: '只读类型',
        describe: '仅编辑引用记录时适用于”嵌套表格2“宏控件选取的记录',
        type: 'select',
        componentProps: {
          placeholder: '请选择',
          readonly: true,
          defaultValue: '',
          allowClear: true,
          options: [
            {
              label: '不限',
              value: '',
            },
            {
              label: '仅添加时',
              value: '0',
            },
            {
              label: '仅编辑时',
              value: '1',
            },
            {
              label: '仅编辑引用记录时',
              value: '2',
            },
          ],
        },
        field: 'readOnlyType',
      },
      {
        label: '提示',
        type: 'textarea',
        field: 'tip',
      },
    ],
    event: [
      {
        type: 'input',
        describe: '输入值',
      },
      {
        type: 'change',
        describe: '值修改',
      },
      {
        type: 'pressEnter',
        describe: '按下回车的回调',
      },
      {
        type: 'focus',
        describe: '获取焦点',
      },
      {
        type: 'blur',
        describe: '失去焦点',
      },
    ],
    action: [
      {
        type: 'focus',
        describe: '使 input 获取焦点',
      },
      {
        type: 'blur',
        describe: '使 input 失去焦点',
      },
      {
        type: 'select',
        describe: '选中 input 中的文字',
      },
    ],
  },
  bindModel: 'modelValue',
} as ComponentConfigModel;
